
<script>


    import {pickerOptions} from "../utils/VueUtils";
    import {DeleteAlert} from "../../components/alert/DeleteAlert";
    import {DateUtils} from "../../util/DateUtils";
    import {SystemLogApi} from "../../api/biz/user/system-log";

    export default {
        data(){
            let start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
          return{
              tablePage: {
                  pageNum: 1,
                  pageSize: 10,
                  total: 0
              },
              tableSelection: [],
              tableSearch: {
                  type:2,
                  date:[start,DateUtils.getDayEndByDate(new Date())]
              },
              tableList: [],
              pickerOptions:pickerOptions
          }
        },
        methods:{
            clickExcelExport(){

            },
            changeSelection(selection) {
                this.tableSelection = selection
            },
            clickSearch(){
                this.updateList()
            },
            clickCreate(){
                this.$refs['dialog'].open()
            },
            clickEdit(row){
                this.$refs['dialog'].open(row)
            },
            clickBatchDelete(data){
                let ids = []
                let name = ''
                if(Array.isArray(data)){
                    for(let item of this.tableSelection){
                        ids.push(item.id)
                    }
                }else{
                    ids.push(data.id)
                    name = data.name
                }

                DeleteAlert(this,name).then(()=>{
                    // SoftVersionApi.deleteBatch({ids:ids.join(',')}).then(res => {
                    //     this.updateList()
                    // });
                })
            },
            updateList(){

                let search = Object.assign({},this.tableSearch,this.tablePage)
                search.startDate = DateUtils.datetimeFormat(DateUtils.getDayStartByDate(search.date[0]))
                search.endDate = DateUtils.datetimeFormat(DateUtils.getDayEndByDate(search.date[1]))
                delete search.date

                SystemLogApi.list(search).then(res => {
                    if (res.data.list !== 0) {
                        this.tableList = res.data.list;
                    } else {
                        this.tableList = [];
                    }
                    this.tablePage.total = res.data.total;

                })
            }
        },mounted() {
            this.tableSearch.type = this.type
            this.updateList()
        }
    }
</script>
